<?php

namespace DebugComponent\Message;

class Error extends Message {

    public function __construct($message) {
        parent::__construct($message);
        $this->traceback = \debug_backtrace();
    }

    public function getTraceback() {
        return $this->traceback;
    }

    public function getFilename() {
        $traceback = $this->getTraceback();
        $traceItem = array_pop($traceback);
        return isset($traceItem['file']) ? $traceItem['file'] : 'unknown';
    }

    public function getLine() {
        $traceback = $this->getTraceback();
        $traceItem = array_pop($traceback);
        return isset($traceItem['line']) ? $traceItem['line'] : 'unknown';
    }

    private $traceback;
}